package com.control.web;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.dao.GoodsInfoDAO;
import com.entity.GoodsInfo;
import com.util.PublicToolCheckParam;
import com.util.PublicToolParam;
import com.util.Validate;

public class Shopping extends HttpServlet {
	private static final long serialVersionUID = 9192246410194090687L;

	@SuppressWarnings("unchecked")
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

	 	String str_gid = Validate.replaceHtml(request.getParameter("gid"));
	 	int gid = Integer.parseInt(str_gid);
		ArrayList<GoodsInfo> shopList =  null;
		shopList = new ArrayList<GoodsInfo>();
		GoodsInfoDAO gdao = new GoodsInfoDAO();
		GoodsInfo gd = gdao.getQueryGoodsInfo(gid);
		shopList.add(gd);
		gd.mySetCount(1);
		HttpSession session = request.getSession();
		session.setAttribute("shopList", shopList);
		response.sendRedirect("../filterWeb/sendInfo.jsp");
	}

	 
	

	protected void service(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub

		String method = Validate.replaceHtml(request.getParameter("method"));

		if (PublicToolCheckParam.checkNullAndEmpty(method)) {
			if (method.equals("g")) {
				doPost(request, response);
			}  
		}
	}

}
